package com.guochenglang.www.pojo;

import java.util.List;

/**
 * 分页查询page类
 *
 * @author GuoChenglang
 */
public class Page<T> {
    /**
     * 页大小
     */
    private Integer pageSize;
    /**
     * 总量
     */

    private Integer totalSize;
    /**
     * 总页数
     */
    private Integer totalCount;
    /**
     * 当前页
     */
    private Integer preNum;
    /**
     * 下一页
     */
    private Integer nextNum;
    /**
     * 首页
     */
    private Integer startNum = 1;

    /**
     * 展示数据
     */
    private List<T> data;

    public Page() {
    }

    public Page(Integer pageSize, Integer totalSize, List<T> data, Integer preNum) {
        this.pageSize = pageSize;
        this.totalSize = totalSize;
        this.data = data;
        //总页数 = (总查询数 + 每页显示的条数 - 1) / 每页显示的条数
        this.totalCount = (totalSize + pageSize - 1) / pageSize;
        this.preNum = preNum;
        this.nextNum = preNum + 1 > this.totalCount ? this.totalCount : (preNum + 1);
    }


    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public Integer getStartNum() {
        return startNum;
    }

    public void setStartNum(Integer startNum) {
        this.startNum = startNum;
    }

    public Integer getNextNum() {
        return nextNum;
    }

    public void setNextNum(Integer nextNum) {
        this.nextNum = nextNum;
    }

    public Integer getPreNum() {
        return preNum;
    }

    public void setPreNum(Integer preNum) {
        this.preNum = preNum;
    }

    public Integer getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

    public Integer getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(Integer totalSize) {
        this.totalSize = totalSize;
    }
}

